home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3421 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: mxsld2.pd.infn.it!LORETI
  3. From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
  4. Subject: Re: Function to retrieve full path name of running process?
  5. X-Nntp-Posting-Host: mxsld2.pd.infn.it
  6. Message-ID: <DLwuC6.CqJ@news.cern.ch>
  7. Sender: news@news.cern.ch (USENET News System)
  8. Reply-To: loreti@mxsld2.pd.infn.it
  9. Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
  10. References: <4e330s$o25@news.fmso.navy.mil>
  11. Date: Sun, 28 Jan 1996 21:28:53 GMT
  12.  
  13. In article <4e330s$o25@news.fmso.navy.mil>, Carol_Walker@fmso.navy.mil (Carol Walker) writes:
  14. >Is there a function that a process running on a Unix system can call
  15. >to determine the full path name of its object file?  argv[0] doesn't 
  16. >contain the full path, only the command used to execute it.
  17. >
  18. >Thanks in advance.
  19. >
  20. >Carol Walker
  21. >US Navy Fleet Material Support Office
  22. >Mechanicsburg, PA
  23. >carol_walker@fmso.navy.mil
  24. >
  25.  
  26. You are out of luck.  As you know having read the FAQ list before
  27. posting,
  28.  
  29. 19.31:    How can my program discover the complete pathname to the
  30.     executable from which it was invoked?
  31.  
  32. A:    argv[0] may contain all or part of the pathname, or it may
  33.     contain nothing.  You may be able to duplicate the command
  34.     language interpreter's search path logic to locate the
  35.     executable if the name in argv[0] is present but incomplete.
  36.     However, there is no guaranteed solution.
  37.  
  38.     References: K&R1 Sec. 5.11 p. 111; K&R2 Sec. 5.10 p. 115; ANSI
  39.     Sec. 2.1.2.2.1; ISO Sec. 5.1.2.2.1; H&S Sec. 20.1 p. 416.
  40.  
  41. --
  42. Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
  43. Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
  44.